package com.coldchain.admin.config.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.coldchain.admin.config.entity.CityInfo;
import com.coldchain.admin.config.mapper.CityInfoMapper;
import com.coldchain.admin.config.service.ICityInfoService;
import com.coldchain.vo.CityInfoVo;
import com.coldchain.common.enums.EnableStatusEnums;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author fangliai
 * @since 2018-11-06
 */
@Service
public class CityInfoServiceImpl extends ServiceImpl<CityInfoMapper, CityInfo> implements ICityInfoService {

    @Override
    public void changeHot(Integer id) {
        CityInfo cityInfo=getById(id);
        cityInfo.setHot(cityInfo.getHot().equals(1)?0:1);
        updateById(cityInfo);
    }

    @Override
    public void changeEnable(Integer id) {
        CityInfo cityInfo=getById(id);
        cityInfo.setEnable(cityInfo.getEnable().equals(EnableStatusEnums.OPEN)?EnableStatusEnums.CLOSE:EnableStatusEnums.OPEN);
        updateById(cityInfo);
    }

    @Override
    public List<CityInfoVo> getCityInfoVo(Map<String, Object> params) {
        return baseMapper.getCityInfoVo(params);
    }
}
